package com.ww.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.ww.sentinel.client.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:
 * @author:
 * @Description:
 * @Date
 **/
@RestController
public class SentinelController {
    @Autowired
    UserClient userClient;

    @GetMapping("/user")
    public String findAllUser() {
        return userClient.findAllUser();
    }


    @GetMapping("/user/findUser")
    @SentinelResource(value = "findUser", blockHandler = "blockHandle")
    public String findUser() {
        return userClient.findUserById();
    }

    @GetMapping("/user/addUser")
    public String add() {
        return userClient.add();
    }


    public String blockHandle() {
        return "我被限流了";
    }

}
